<template>
    <view>
        <cu-custom bgColor="bg-grey light" :isBack="true">
            <view slot="backText">返回</view>
            <view slot="content">蹭课</view>
        </cu-custom>

        <loginModal style="z-index:600" :showLoginModal.sync="isLoginModalShow" @loginModalConfirm="loginModalConfirm">
        </loginModal>

        <view :style="'position: fixed;right: 0;bottom: 0;left: 0;top:' + CustomBar + 'px;'">
            <view>
                <view class="flex justify-center padding-sm text-center">
                    <view :class="'load-progress ' + (loadProgress != 0 ? 'show' : 'hide')"
                        :style="'top:' + CustomBar + 'px;'">
                        <view class="load-progress-bar bg-black"
                            :style="'transform: translate3d(-' + (100 - loadProgress) + '%, 0px, 0px);'"></view>
                        <view class="load-progress-spinner text-black"></view>
                    </view>
                    <view class="margin-lr-sm">
                        <button class="cu-btn icon round line-orange" @tap="toLastWeek" role="button"
                            :aria-disabled="false">
                            <text class="cuIcon-back text-xl"></text>
                        </button>
                    </view>
                    <view class="margin-right-sm">
                        <button style="width: 200rpx" class="line-blue cu-btn" role="button" :aria-disabled="false">
                            <picker @change="pickerChangeTopWeek" :value="nowWeek" :range="weekArrAll">
                                <text class="text-df">{{ weekArrAll[nowWeek] }}</text>
                            </picker>
                        </button>
                    </view>
                    <view>
                        <button class="line-pink cu-btn" @tap="showSetting" role="button" :aria-disabled="false">
                            <text class="text-df">设置</text>
                        </button>
                    </view>
                    <view class="margin-lr-sm">
                        <button class="cu-btn icon round line-orange" @tap="toNextWeek" role="button"
                            :aria-disabled="false">
                            <text class="cuIcon-right text-xl"></text>
                        </button>
                    </view>
                </view>
            </view>

            <view
                :style="'height:100%;background-image:url(' + backGroundImg + ');background-repeat:no-repeat;background-size:auto 100%'">
                <view style="height: 100%">
                    <view style="background-color: #f1f1f1; opacity: 0.9; padding-top: 12rpx">
                        <view class="flex solid-bottom">
                            <view style="width: 32rpx; padding-top: 0rpx">
                                <view class="grid col-1 kebiao text-center">
                                    <view class="">{{ month }}月</view>
                                </view>
                            </view>
                            <view style="flex: 10">
                                <view class="grid col-7 text-center">
                                    <view v-for="(item, index) in weekArrTop" :key="index">
                                        <view :class="
                                                'grid col-1 light text-center ' +
                                                (item === nowDay ? (month === nowMonth ? (year === nowYear ? 'bg-brown radius' : '') : '') : '')
                                            ">
                                            <view>{{ weekArr[index] }}</view>
                                            <view>{{ item }}日</view>
                                        </view>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>

                    <view style="height: 100%; overflow: scroll">
                        <view class="flex kebiao-content">
                            <view class="bg-grey light"
                                style="width: 35rpx; opacity: 0.8 !important; margin-right: 3rpx">
                                <view class="grid col-1 kebiao-left text-center">
                                    <view>1</view>
                                    <view>2</view>
                                    <view>3</view>
                                    <view>4</view>
                                    <view>5</view>
                                    <view>6</view>
                                    <view>7</view>
                                    <view>8</view>
                                    <view>9</view>
                                    <view>10</view>
                                </view>
                            </view>
                            <view style="flex: 10">

                                <view v-if="days && isThisWeek" class="grid col-7 text-center">
                                    <view class="grid col-1 text-center" v-for="(item, currentDay) in 7"
                                        :key="currentDay">
                                        <view class="course_tag0" v-for="(item, currentClass) in 10"
                                            :key="currentClass">

                                            <view v-for="(item, index) in days[currentDay][currentClass]" :key="index"
                                                v-if="item.startClass == currentClass + 1 && nowWeek >= item.startWeek && nowWeek <= item.endWeek"
                                                class="course_tag2" :style="'height:' + item.length * biaoZhun + 'px'">
                                                <view
                                                    :class="'course_tag3  bg-' + ((currentDay + currentClass) % 9) + ' radius text-sm '"
                                                    :data-id="[currentDay, currentClass, index]" @tap="showDetail">
                                                    <view class="text-cut" style="height: 40rpx">{{ item.name }}
                                                    </view>
                                                    <view>{{ item.where }}</view>
                                                </view>
                                            </view>

                                        </view>
                                    </view>
                                </view>

                                <view v-if="days && !isThisWeek" class="grid col-7 text-center">
                                    <view class="grid col-1 text-center" v-for="(item, currentDay) in 7"
                                        :key="currentDay">
                                        <view class="course_tag0" v-for="(item, currentClass) in 10"
                                            :key="currentClass">


                                            <view v-if="days[currentDay][currentClass].length == 1" class="course_tag2"
                                                :style="'height:' + days[currentDay][currentClass][0].length * biaoZhun + 'px'">
                                                <view
                                                    :class="'course_tag3  bg-' + ((currentDay + currentClass) % 9) + ' radius text-sm '"
                                                    :data-id="[currentDay, currentClass, 0]" @tap="showDetail">

                                                    <view class="text-cut" style="height: 40rpx">
                                                        {{ days[currentDay][currentClass][0].name }}
                                                    </view>
                                                    <view>{{ days[currentDay][currentClass][0].where }}</view>
                                                </view>


                                            </view>

                                            <view class="course_tag2" v-if="days[currentDay][currentClass].length > 1"
                                                :style="'height:' + days[currentDay][currentClass][0].length * biaoZhun + 'px'">

                                                <view
                                                    :class="'course_tag3 bg-' + ((currentDay + currentClass) % 9) + ' radius text-sm'"
                                                    :data-id="[currentDay, currentClass]" @tap="showChooseCourse">
                                                    <view class="text-cut" style="height: 40rpx"
                                                        v-for="(item, index) in days[currentDay][currentClass]"
                                                        :key="index">
                                                        {{ item.name }}
                                                    </view>
                                                    <view text-bold>*有多节</view>
                                                </view>
                                            </view>



                                        </view>
                                    </view>
                                </view>

                            </view>
                        </view>
                    </view>
                </view>
            </view>
        </view>


        <view :class="'cu-modal ' + (isDetailShow ? 'show' : '')">
            <view class="cu-dialog bg-white" style="width: 500rpx">
                <view class="cu-bar bg-white justify-end">
                    <view class="content">课程详情</view>
                    <view class="action" @tap="hideDetail">
                        <text class="cuIcon-close text-purple"></text>
                    </view>
                </view>
                <view class="bg-white">
                    <view class="action text-lg text-bold padding-sm text-left">
                        <text class="cuIcon-title text-cyan margin-lr-lg"></text>
                        {{ detailName }}
                    </view>
                    <view class="action text-lg padding-sm text-left">
                        <text class="cuIcon-location text-orange margin-lr-lg"></text>
                        {{ detailWhere }}
                    </view>
                    <view class="action text-lg padding-sm text-left">
                        <text class="cuIcon-calendar text-purple margin-lr-lg"></text>
                        {{ detailWeekInfo }}
                    </view>
                    <view class="action text-lg padding-sm text-left">
                        <text class="cuIcon-info text-pink margin-lr-lg"></text>
                        {{ detailCourseInfo }}
                    </view>
                    <view class="action text-lg padding-sm margin-bottom-lg text-left">
                        <text class="cuIcon-friendfamous text-blue margin-lr-lg"></text>
                        {{ detailTeacher }}
                    </view>
                </view>
            </view>
        </view>

        <view :class="'cu-modal ' + (isChooseCourseShow ? 'show' : '') ">
            <view class="cu-dialog bg-white">
                <view class="cu-bar bg-white justify-end">
                    <view class="content">选择课程</view>
                    <view class="action" @tap="hideChooseCourse">
                        <text class="cuIcon-close text-purple"></text>
                    </view>
                </view>
                <view :class="'bg-white grid col-' + moreCourseArr.length + ' text-center'">
                    <view class="padding" v-for="(item, index) in moreCourseArr" :key="item.key">
                        <view @tap="showDetail" :data-id="[choosedWeek, choosedClass, index]" :class="
							'bg-' +
							(item.startClass == choosedClass + 1 ? (nowWeek >= item.startWeek ? (nowWeek <= item.endWeek ?
								index % 8 : 'grey' ) : 'grey' ) : 'grey' )
								+ '  padding light  radius text-center text-df shadow-blur' " style=" height: 200rpx">
                            <view class="text-cut" style="height: 40rpx">{{ item.name }}</view>
                            <view class="more0">{{ item.where }}</view>
                        </view>
                    </view>
                </view>
            </view>
        </view>

        <view :class="'cu-modal ' + (isSettingShow == 'show' ? 'show' : '')">
            <view class="cu-dialog">
                <view class="cu-bar bg-white justify-end">
                    <view class="content">设置</view>
                    <view class="action" @tap="hideSetting">
                        <text class="cuIcon-close text-red"></text>
                    </view>
                </view>
                <view class="">
                    <view class="grid col-1 margin-bottom text-center">
                        <view class="cu-form-group">
                            <view class="title">只显示本周</view>
                            <switch @change="changeIsThisWeek" :checked="isThisWeekTemp" class="red sm"></switch>
                        </view>
                        <view class="cu-form-group">
                            <view class="title">显示在主页</view>
                            <switch @change="changIsShowHome" :checked="isShowHomeTemp" class="red sm"></switch>
                        </view>
                        <view @tap="showDetailSetting" class="cu-form-group xx-seting">
                            <view class="title">信息设置</view>
                            <view style="height: 100rpx; position: relative"></view>
                        </view>
                    </view>
                    <view class="cu-bar bg-white justify-end">
                        <view class="action">
                            <button class="cu-btn line-black text-green" @tap="hideSetting">取消</button>
                            <button class="cu-btn bg-black margin-left" @tap="confirmChange">确定</button>
                        </view>
                    </view>
                </view>
            </view>
        </view>

        <view :class="'cu-modal ' + (isDetailSettingShow == 'show' ? 'show' : '')">
            <view class="cu-dialog">
                <view class="cu-bar bg-white justify-end">
                    <view class="content">设置</view>
                    <view class="action" @tap="hideDetailSetting">
                        <text class="cuIcon-close text-red"></text>
                    </view>
                </view>
                <view class="">
                    <view class="grid col-1 margin-bottom text-center">
                        <view class="cu-form-group">
                            <view class="title">选择学期</view>
                            <picker mode="multiSelector" @change="MultiChange" :value="termTemp" :range="termArr">
                                <view class="picker">{{ termArr[0][termTemp[0]] }}，{{ termArr[1][termTemp[1]] }}
                                </view>
                            </picker>
                        </view>
                        <view class="cu-form-group">
                            <view class="title">选择年级</view>
                            <picker mode="selector" @change="MultiChange2" :value="gradesTemp" :range="grades">
                                <view class="picker">
                                    {{ grades[gradesTemp] }}
                                </view>
                            </picker>
                        </view>
                        <view class="cu-form-group">
                            <view class="title">选择院系</view>
                            <picker mode="selector" @change="MultiChange3" :value="collegeTemp" :range="college">
                                <view class="picker">
                                    {{ college[collegeTemp] }}
                                </view>
                            </picker>
                        </view>
                        <view class="cu-form-group">
                            <view class="title">选择专业</view>
                            <picker mode="selector" @change="MultiChange4" :value="majorTemp" :range="major">
                                <view class="picker">
                                    {{ major[majorTemp] }}
                                </view>
                            </picker>
                        </view>
                        <view class="cu-form-group">
                            <view class="title">选择班级</view>
                            <picker mode="selector" @change="MultiChange5" :value="classTemp" :range="classArr">
                                <view class="picker">
                                    {{ classArr[classTemp] }}
                                </view>
                            </picker>
                        </view>
                    </view>
                </view>
                <view class="cu-bar bg-white justify-end">
                    <view class="action">
                        <button class="cu-btn line-black text-green" @tap="hideDetailSetting">取消</button>
                        <button class="cu-btn bg-black margin-left" @tap="confirmDetailChange">确定</button>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
    // pages/kebiao/index.js
    const app = getApp();
    import loginModal from '@/pages/login-modal/index'
    import {
        getClass
    } from '../../utils/cengke/getClass.js'
    import {
        getCollege
    } from '../../utils/cengke/getCollege.js'
    import {
        getMajor
    } from '../../utils/cengke/getMajor.js'
    import {
        getDays
    } from '../../utils/cengke/getKebiao.js'
    export default {
        components: {
            loginModal,
        },
        data() {
            return {
                CustomBar: app.globalData.CustomBar,
                isLoginModalShow: false,
                nowDate: '',
                nowMonth: new Date().getMonth() + 1,
                nowYear: new Date().getFullYear(),
                nowDay: new Date().getDate(),
                nowWeek: 0,
                nowWeekTemp: 0,
                weekBegin: 0,
                weekStartTemp: 0,
                month: '',
                year: '',
                nowDate: '',
                weekArrTop: '',
                weekArr: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
                weekArrAll: [
                    '未开始',
                    '第一周',
                    '第二周',
                    '第三周',
                    '第四周',
                    '第五周',
                    '第六周',
                    '第七周',
                    '第八周',
                    '第九周',
                    '第十周',
                    '第十一周',
                    '第十二周',
                    '第十三周',
                    '第十四周',
                    '第十五周',
                    '第十六周',
                    '第十七周',
                    '第十八周',
                    '第十九周',
                    '第二十周',
                    '第二十一周',
                    '第二十二周',
                    '第二十三周',
                    '第二十四周',
                    '第二十五周',
                    '假期中'
                ],
                termArr: [
                    ['', '', '', ''],
                    ['', '']
                ],
                term: [3, 0],
                termTemp: [3, 0],
                grades: [],
                gradesTemp: 0,
                college: ['未获取'],
                collegeTemp: '',
                major: ['未获取'],
                majorTemp: '',
                classArr: ['未获取'],
                classTemp: '',
                isSettingShow: false,
                isThisWeek: true,
                isThisWeekTemp: true,
                isShowHome: false,
                isShowHomeTemp: false,
                loadProgress: 0,
                isDetailShow: false,
                isDetailSettingShow: false,
                detailWhere: '',
                detailWeekInfo: '',
                detailCourseInfo: '',
                detailTeacher: '',
                detailName: '',
                isChooseCourseShow: false,
                moreCourseArr: '',
                backGroundImgTemp: '',
                backGroundImg: '',
                isLoad: false,
                biaoZhun: '',
                days: false
            };
        }
        /**
         * 生命周期函数--监听页面初次渲染完成
         */
        ,
        onReady: function() {},
        /**
         * 生命周期函数--监听页面加载
         */
        onLoad: function(options) {
            let that = this;
            uni.getStorage({
                key: 'userID',

                fail() {
                    uni.redirectTo({
                        url: '/pages/login/index'
                    });
                },

                success() {
                    that.doSuccess();
                }
            });
        },
        /**
         * 生命周期函数--监听页面显示
         */
        onShow: function() {},
        /**
         * 生命周期函数--监听页面隐藏
         */
        onHide: function() {},
        /**
         * 生命周期函数--监听页面卸载
         */
        onUnload: function() {},
        /**
         * 页面相关事件处理函数--监听用户下拉动作
         */
        onPullDownRefresh: function() {},
        /**
         * 页面上拉触底事件的处理函数
         */
        onReachBottom: function() {},
        /**
         * 用户点击右上角分享
         */
        onShareAppMessage: function() {},
        methods: {
            doSuccess() {
                let that = this;
                let nowDate = new Date();
                let nowYear = nowDate.getFullYear();
                let nowMonth = nowDate.getMonth();

                let k = 1;
                if (nowMonth > 6) {
                    k = 0;
                }

                let termArr = [new Array(4), ["第一学期", "第二学期"]];
                for (let i = 0; i < 4; i++) {
                    termArr[0][i] = nowYear - (3 - i) - k + '-' + (nowYear + (i - 2) - k);
                }

                let grades = ['未选择'];

                for (var i = 0; i < 4; i++) {
                    grades.push(nowYear - i - k);
                }

                this.setData({
                    grades,
                    gradesTemp: 0
                });
                var dn_s = [0, 31, 28, 31, 20, 31, 30, 31, 31, 30, 31, 30, 31];

                if (nowYear % 4 == 0 || nowYear % 100 == 0) {
                    dn_s[2] = 29;
                }

                var windowWidth;
                var windowHeigth;
                uni.getSystemInfo({
                    success: function(res) {
                        windowWidth = res.windowWidth;
                        windowHeigth = res.windowHeight; //console.log(windowHeigth)
                    }
                });
                let biaoZhun;

                if (windowHeigth > 0 && windowHeigth <= 570) {
                    biaoZhun = 40;
                } else if (windowHeigth > 570 && windowHeigth <= 800) {
                    biaoZhun = 50;
                } else if (windowHeigth > 800 && windowHeigth <= 900) {
                    biaoZhun = 60;
                } else {
                    biaoZhun = 100;
                }

                this.setData({
                    biaoZhun: biaoZhun
                });
                this.keBiaoDataWeekBegin = uni.getStorageSync('keBiaoDataWeekBegin');
                this.weekStartTemp = new Date(new Date().toLocaleDateString()).getTime() - ((new Date().getDay() == 0 ?
                    7 : new Date().getDay()) - 1) * 86400000;

                if (this.keBiaoDataWeekBegin == '') {
                    this.keBiaoDataWeekBegin = this.weekStartTemp;
                    uni.setStorageSync('keBiaoDataWeekBegin', this.weekStartTemp);
                }

                let timeTemp = new Date().getTime();
                this.setData({
                    nowDate: timeTemp
                });
                this.getDates(timeTemp);

                let weekTemp = Math.ceil((timeTemp - this.keBiaoDataWeekBegin) / 604800000);

                if (weekTemp > 26) {
                    weekTemp = 26;
                }

                this.setData({
                    days: uni.getStorageSync('cengKeKeBiaoData'),
                    isThisWeek: uni.getStorageSync('cengKeSetIsThisWeek'),
                    isShowHome: uni.getStorageSync('cengKeSetIsShowHome'),
                    keBiaoDataWeekBegin: uni.getStorageSync('keBiaoDataWeekBegin'),
                    backGroundImg: uni.getStorageSync('keBiaoSetBackGroundImg'),
                    nowWeek: weekTemp,
                    nowWeekTemp: weekTemp,
                    biaoZhun,
                    termArr
                });

                uni.getStorage({
                    key: 'cengKeKeBiaoData',
                    fail() {
                        that.setData({
                            isThisWeek: false,
                            isShowHome: false,
                            termTemp: [3, k]
                        });
                        that.showSetting();
                    }
                });

            },

            pickerChangeTopWeek(e) {
                let temp;

                if (this.nowWeek < parseInt(e.detail.value)) {
                    temp = parseInt(e.detail.value) - this.nowWeek;
                    this.getDates(this.nowDate + 604800000 * temp);
                    this.setData({
                        nowWeek: this.nowWeek + temp
                    });
                } else if (this.nowWeek > parseInt(e.detail.value)) {
                    temp = this.nowWeek - parseInt(e.detail.value);
                    this.getDates(this.nowDate - 604800000 * temp);
                    this.setData({
                        nowWeek: this.nowWeek - temp
                    });
                }
            },

            async getCollege() {
                uni.showLoading({
                    title: '正在获取院系'
                });
                let that = this;

                let res = await getCollege()
                console.log(res)
                uni.hideLoading()
                if (res == null) {
                    that.showLoginModal();
                    that.setData({
                        isLoad: false
                    });
                    return
                }

                that.setData({
                    college: res.college,
                    collegeIdArr: res.collegeIdArr,
                    collegeTemp: 0
                })
            },

            MultiChange(e) {
                this.setData({
                    termTemp: e.detail.value
                });
            },

            async MultiChange2(e) {
                this.setData({
                    gradesTemp: e.detail.value
                });
                console.log(this.gradesTemp)

                if (this.major.length > 1) {
                    uni.showLoading({
                        title: '正在获取班级'
                    });
                    let that = this;

                    let res = await getClass(that.majorIdArr[that.majorTemp], that.grades[that.gradesTemp], that
                        .collegeIdArr[
                            that
                            .collegeTemp])
                    console.log(res)
                    uni.hideLoading()
                    if (res == null) {
                        that.showLoginModal();
                        that.setData({
                            isLoad: false
                        });
                        return
                    }

                    uni.hideLoading();
                    that.setData({
                        classArr: res.classArr,
                        classIdArr: res.classIdArr,
                        classTemp: 0
                    });

                }
            },

            async MultiChange3(e) {
                uni.showLoading({
                    title: '正在获取专业'
                });
                this.setData({
                    collegeTemp: e.detail.value
                });
                let that = this;
                let res = await getMajor(that.collegeIdArr[e.detail.value])
                console.log(res)
                uni.hideLoading()
                if (res == null) {
                    that.showLoginModal();
                    that.setData({
                        isLoad: false
                    });
                    return
                }
                uni.hideLoading();
                that.setData({
                    major: res.major,
                    majorIdArr: res.majorIdArr
                });
            },

            async MultiChange4(e) {
                this.setData({
                    majorTemp: e.detail.value
                });
                uni.showLoading({
                    title: '正在获取班级'
                });
                let that = this;
                let res = await getClass(that.majorIdArr[that.majorTemp], that.grades[that.gradesTemp], that
                    .collegeIdArr[that
                        .collegeTemp])
                console.log(res)
                uni.hideLoading()
                if (res == null) {
                    that.showLoginModal();
                    that.setData({
                        isLoad: false
                    });
                    return
                }
                that.setData({
                    classArr: res.classArr,
                    classIdArr: res.classIdArr,
                    classTemp: 0
                });
            },

            MultiChange5(e) {
                this.setData({
                    classTemp: e.detail.value
                });
            },

            loadProgressFun() {
                this.setData({
                    loadProgress: this.loadProgress + 3
                });

                if (this.loadProgress < 100) {
                    setTimeout(() => {
                        this.loadProgressFun();
                    }, 100);
                } else {
                    this.setData({
                        loadProgress: 0
                    });
                }
            },

            async refresh() {
                this.loadProgressFun();
                let that = this;
                uni.showLoading({
                    title: '正在获取中'
                });
                var term0 = this.termArr[0][this.termTemp[0]];
                var term1;

                if (this.termTemp[1] == 0) {
                    term1 = '-1-1';
                } else {
                    term1 = '-2-1';
                }

                let res = await getDays(term0, term1, that.classIdArr[this.classTemp])
                console.log(res)
                uni.hideLoading()
                if (res == null) {
                    that.showLoginModal();
                    that.setData({
                        isLoad: false
                    });
                    return
                }

                uni.hideLoading();
                uni.showToast({
                    title: '获取成功'
                });


                uni.setStorageSync('cengKeKeBiaoData', res);
                that.setData({
                    days: res,
                    loadProgress: 100,
                });
            },

            loginModalConfirm(e) {
                this.getCollege()
            },

            showLoginModal() {
                this.setData({
                    isLoginModalShow: true
                });
            },

            toNextWeek() {
                if (parseInt(this.nowWeek) > 25) {
                    return;
                }

                this.getDates(this.nowDate + 604800000);
                this.setData({
                    nowWeek: parseInt(this.nowWeek) + 1
                });
            },

            toLastWeek() {
                if (this.nowWeek == 0) {
                    return;
                }

                this.getDates(this.nowDate - 604800000);
                this.setData({
                    nowWeek: parseInt(this.nowWeek) - 1
                });
            },

            showSetting() {
                this.setData({
                    isThisWeekTemp: this.isThisWeek,
                    isShowHomeTemp: this.isShowHome
                });
                this.setData({
                    isSettingShow: 'show'
                });
            },

            showDetailSetting() {
                this.setData({
                    termTemp: this.term,
                    gradesTemp: 0,
                    collegeTemp: 0,
                    majorTemp: 0,
                    classTemp: 0,
                    isDetailSettingShow: 'show'
                });
                this.getCollege();
            },

            showDetail(e) {
                let currentDay = e.currentTarget.dataset.id[0]
                let currentClass = e.currentTarget.dataset.id[1]
                let currentNum = e.currentTarget.dataset.id[2]
                let currentDetail = this.days[currentDay][currentClass][currentNum]
                this.setData({
                    isDetailShow: true,
                    detailName: currentDetail.name,
                    detailWhere: currentDetail.where,
                    detailCourseInfo: currentDetail.startWeek + '-' + currentDetail.endWeek + ' 周',
                    detailWeekInfo: this.weekArrAll[currentDay] + ' ' + currentClass + '-' + (currentDetail
                        .startClass +
                        currentDetail.length - 1) + ' 节',
                    detailTeacher: currentDetail.teacher,
                    isChooseCourseShow: false
                });
            },

            hideDetail(e) {
                this.setData({
                    isDetailShow: false,
                });
            },


            confirmChange() {
                this.setData({
                    isThisWeek: this.isThisWeekTemp,
                    isShowHome: this.isShowHomeTemp,
                    isSettingShow: ''
                });

                uni.setStorageSync('cengKeSetIsThisWeek', this.isThisWeekTemp);
                uni.setStorageSync('cengKeSetIsShowHome', this.isShowHomeTemp);
            },

            confirmDetailChange() {
                if (this.gradesTemp != 0 && this.collegeTemp != 0 && this.majorTemp != 0) {
                    this.setData({
                        term: this.termTemp
                    });
                    this.refresh();
                } else {
                    uni.showToast({
                        title: '信息不全',
                        duration: 1000,
                        icon: 'none'
                    });
                }

                this.hideDetailSetting();
            },

            hideSetting() {
                this.setData({
                    isSettingShow: ''
                });
            },

            hideDetailSetting() {
                this.setData({
                    isDetailSettingShow: ''
                });
            },

            changeIsThisWeek(e) {
                this.isThisWeekTemp = e.detail.value;
            },

            changIsShowHome(e) {
                this.isShowHomeTemp = e.detail.value;
            },

            getDates(currentTime) {
                var currentDate = new Date(currentTime);
                var timesStamp = currentDate.getTime();
                var currenDay = currentDate.getDay();
                var month = currentDate.getMonth() + 1;
                var year = currentDate.getFullYear();
                var dates = [];

                for (var i = 0; i < 7; i++) {
                    dates.push(new Date(timesStamp + 24 * 60 * 60 * 1000 * (i - ((currenDay + 6) % 7))).getDate());
                }

                this.setData({
                    weekArrTop: dates,
                    nowDate: currentTime,
                    month: month,
                    year: year
                });
            },

            showChooseCourse(e) {
                let currentDay = e.currentTarget.dataset.id[0]
                let currentClass = e.currentTarget.dataset.id[1]
                let courses = this.days[currentDay][currentClass];
                this.setData({
                    moreCourseArr: courses,
                    choosedWeek: currentDay,
                    choosedClass: currentClass,
                    isChooseCourseShow: true
                });
            },

            hideChooseCourse() {
                this.setData({
                    isChooseCourseShow: false
                });
            },
        }
    };
</script>
<style>
    @import './index.css';
</style>
